Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

C # Programming interview questions


What is C#?

C# is a modern, object-oriented programming language developed by Microsoft. It runs on the .NET Framework and is used to develop applications ranging from web to desktop and mobile applications.

What are the fundamental principles of OOP (Object-Oriented Programming)?

The fundamental principles of OOP are Encapsulation, Inheritance, Polymorphism, and Abstraction.

What is the difference between a class and an object?

A class is a blueprint or template for creating objects. An object is an instance of a class..

What is inheritance in C#?

Inheritance is a feature of OOP where a new class (derived class) inherits properties and behavior (methods) from an existing class (base class)

Explain polymorphism in C#.

Answer: Polymorphism allows methods to do different things based on the object it is acting upon. It can be achieved through function overloading, operator overloading, and method overriding (via virtual functions).

What is an interface in C#?

An interface defines a contract that implementing classes must adhere to. It contains definitions for a group of related functionalities that a class or struct can implement..

What is the difference between an abstract class and an interface?

An abstract class can have implementations for some of its members, but an interface cannot. A class can implement multiple interfaces but can inherit only one abstract class.


What is encapsulation?

Encapsulation is the bundling of data with the methods that operate on that data. It restricts direct access to some of an object's components and can prevent the accidental modification of data. .

What is a delegate in C#?

A delegate is a type-safe function pointer. It allows methods to be passed as parameters and can be used to define callback methods.

What is an event in C#?

n event is a message sent by an object to signal the occurrence of an action. Events are typically used in conjunction with delegates.


Explain the difference between ref and out parameters.

Both ref and out are used to pass arguments by reference. ref requires that the variable be initialized before it is passed, while out does not require initialization before being passed but must be assigned a value before the method returns.


What is LINQ?

LINQ (Language Integrated Query) is a set of features in C# that provides query capabilities directly in the C# language, allowing you to write queries for databases, collections, XML, and more in a consistent manner.


What are nullable types in C#?

Nullable types allow value types (such as int, float, etc.) to represent all the values of their underlying type plus an additional null value.


What is the difference between String and StringBuilder in C#?

String is immutable, meaning any operation that appears to modify it actually creates a new string. StringBuilder is mutable, meaning it can be modified without creating a new object, which is more efficient for frequent or large string manipulations.

What are access modifiers in C#?

The access specifiers in C++ are public, private, and protected. They define the access level of class members.

What is the difference between == and Equals() in C#?

.

What is garbage collection in C#?

Garbage collection is an automatic memory management feature in .NET that reclaims memory occupied by objects that are no longer in use.

Explain async and await in C#.

async and await are used to write asynchronous code more easily. async marks a method as asynchronous, and await is used to wait for an asynchronous operation to complete without blocking the main thread.

What are extension methods in C#?

Extension methods allow you to add new methods to existing types without modifying the original type. They are defined as static methods but are called as if they were instance methods on the extended type .

What is a lambda expression in C#?

A lambda expression is a concise way to represent an anonymous function. It uses the => syntax and can be used to create delegates or expression tree types.




Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML 5

Python

java

C++

C

JavaScript

Campus Learning

C

C#

java